package com.coffee.minio;

import io.minio.MinioClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author songkui
 * @since 2022-2-3 11:32
 */
@Configuration
public class MinioConfiguration
{

    @Bean
    public MochaMinioProperties minioProperties()
    {
        return new MochaMinioProperties();
    }


    @Bean
    public MinioClient minioClient(MochaMinioProperties mochaMinioProperties){
       return MinioClient.builder()
                    .endpoint(mochaMinioProperties.getEndpoint())
                    .credentials(mochaMinioProperties.getAccess(), mochaMinioProperties.getSecret())
                    .build();
    }

    @Bean
    public MochaMinioTemplate mochaMinioTemplate(MinioClient minioClient, MochaMinioProperties mochaMinioProperties){
        return new MochaMinioTemplate(minioClient, mochaMinioProperties);
    }


}
